﻿//==============================================================================
//  File Name   :   WebUpdatePanel.cs
//
//  Copyright © 2007 by Do Hong Ngoc. All rights reserved.
//
//  Distributable under GPL code license.
//  See terms of license at www.bbquyen.com.
//
//==============================================================================

// <fileinformation>
//   <summary>
//     This file defines the WebUpdatePanel class.
//   </summary>
//   <author name="Do Hong Ngoc" mail="whiterose1611vn@yahoo.co.uk"/>
//   <date>4/13/2007 2:36:53 PM</date>
//   <remarks>
//     
//   </remarks>
// </fileinformation>

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;

namespace Bbq.Gallery.UI
{
	#region FloatMode
	public enum FloatMode
	{
		None,
		Left,
		Right
	}
	#endregion

	/// <summary>
	/// Defines WebUpdatePanel class.
	/// </summary>
	public class WebUpdatePanel : UpdatePanel
	{
		#region Constants
		#endregion

		#region Private Fields
		#endregion

		#region Public Protected Properties
		/// <summary>
		/// Gets or sets the width.
		/// </summary>
		/// <value>The width.</value>
		public Unit Width
		{
			get
			{
				object obj = this.ViewState["Width"];
				return obj == null ? Unit.Empty : (Unit)obj;
			}
			set { this.ViewState["Width"] = value; }
		}

		/// <summary>
		/// Gets or sets the height.
		/// </summary>
		/// <value>The height.</value>
		public Unit Height
		{
			get
			{
				object obj = this.ViewState["Height"];
				return obj == null ? Unit.Empty : (Unit)obj;
			}
			set { this.ViewState["Height"] = value; }
		}

		/// <summary>
		/// Gets or sets the padding.
		/// </summary>
		/// <value>The padding.</value>
		public Padding Padding
		{
			get
			{
				object obj = this.ViewState["Padding"];
				return obj == null ? Padding.Empty : (Padding)obj;
			}
			set { this.ViewState["Padding"] = value; }
		}

		/// <summary>
		/// Gets or sets the float.
		/// </summary>
		/// <value>The float.</value>
		public FloatMode Float
		{
			get
			{
				object obj = this.ViewState["Float"];
				return obj == null ? FloatMode.None : (FloatMode)obj;
			}
			set { this.ViewState["Float"] = value; }
		}
		#endregion

		#region Internal Private Properties
		#endregion

		#region Constructors
		/// <summary>
		/// Initializes a new instance of the <see cref="WebUpdatePanel"/> class.
		/// </summary>
		public WebUpdatePanel()
		{
		}
		#endregion

		#region Public Protected Functions
		/// <summary>
		/// Renders the children.
		/// </summary>
		/// <param name="writer">The writer.</param>
		protected override void RenderChildren(HtmlTextWriter writer)
		{
			if (this.IsInPartialRendering)
			{
				base.RenderChildren(writer);
			}
			else
			{
				//Initialization for default gallery item
				if (!this.Width.IsEmpty)
					writer.AddStyleAttribute(HtmlTextWriterStyle.Width, this.Width.ToString());
				if (!this.Height.IsEmpty)
					writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
				if (this.Float != FloatMode.None)
					writer.AddStyleAttribute("float", this.Float.ToString().ToLower());
				if (this.Padding.All == -1 || this.Padding.All > 0)
					writer.AddStyleAttribute(HtmlTextWriterStyle.Padding,
						string.Format("{0}px {1}px {2}px {3}px",
						this.Padding.Top, this.Padding.Right, this.Padding.Bottom, this.Padding.Left));
				base.RenderChildren(writer);
			}
		}
		#endregion

		#region Internal Private Functions
		#endregion

		#region Events
		#endregion

	}
}
